//
//  JoTextNode.swift
//  soapp
//
//  Created by zhu xietong on 2018/5/2.
//

import Foundation
import AsyncDisplayKit
public class JoTextNode:MoDisplayNode{
    public let textNode = ASTextNode2()
    
    public var inset:UIEdgeInsets
    public required init() {
        self.inset = UIEdgeInsets(top: 2, left: 0, bottom: 0, right: 0)
        super.init()
        self.isUserInteractionEnabled = false
    }

    public override func specGetter() -> _Spec {
        return .stack(["h",_justfy(.center),&-.center,[inset.top,inset.left,inset.bottom,inset.right]], childs: [
            textNode[_shrink(1),_grow(1)]
        ])
    }
    override open func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {
        return fastLayoutSpec(_spec: specGetter())
    }
    
    public var attributedText:NSAttributedString?{
        set{
            self.textNode.attributedText = newValue
        }
        get{
            return self.textNode.attributedText
        }
    }
}
